<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改问卷记录')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-record-edit" th:object="${qaRecord}">
        <div class="middle-box text-center animated fadeInDown">
            <h2>问卷调查</h2>
        </div>
        <input name="recordId" th:field="*{recordId}" type="hidden">
        <input name="recordId" th:field="*{themeId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">
                姓名：</label>
            <div class="col-sm-8">
                <input name="name" th:field="*{name}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">
                年龄：</label>
            <div class="col-sm-8">
                <input name="age"  class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">性别：</label>
            <div class="col-sm-8">
                <label class="radio-box">
                    <input type="radio" th:field="*{sex}" value="男" name="sex">男</label>
                <label class="radio-box">
                    <input type="radio" value="女" th:field="*{sex}" name="sex">女</label>
                <label class="radio-box">
                    <input type="radio" checked="true" value="未知性别" th:field="*{sex}" name="sex">未知性别</label>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">
                建议：</label>
            <div class="col-sm-8">
                <textarea name="remark" th:field="*{remark}" class="form-control"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10 text-center">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>提 交</button>&nbsp;
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "qa/record";
    $("#form-record-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.ajax({
                url: prefix + "/add",
                data: $('#form-record-edit').serialize(),
                type: "post",
                success: function(result) {
                    if (result.code == web_status.SUCCESS) {
                        layer.msg("保存成功,正在刷新数据请稍后……", {
                            icon: 1,
                            time: 500,
                            shade: [0.1, '#8F8F8F']
                        },function() {
                            location.href = ctx + "qa/thanks?q=" + result.data;
                        });
                    } else {
                        alert(result.msg);
                    }
                }
            })

            // $.operate.save(prefix + "/edit", $('#form-record-edit').serialize());
        }
    }
</script>
</body>
</html>